<?php
$subject = getInput("subject","");
$comments = getInput("comments","");
$emailTo = getInput("emailTo", MAIL_TO);

if ($subject != "" && $comments != ""){
	$comments = str_replace("\n","<br />", $comments);
	$comments = str_replace("\r","<br />", $comments);
	$user = getUserLoggedIn();
	$userText = $user->attributes->firstName . " " . $user->attributes->lastName . ": <br />";
	$comments = $userText . $comments;
	sendNotificationEmail($comments, $subject, $emailTo, MAIL_TO_NAME);
	logSuccess(langEcho("faq:email:send:success"));
	echoJsonResponse(true, $_SERVER["HTTP_REFERER"]);
}else{
	echoJsonResponse(false, "", langEcho("faq:email:send:error"));
}
?>